package org.apache.jsp.pages;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.Map;

public final class page_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.List _jspx_dependants;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("﻿\r\n");
      out.write("\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\r\n");
      out.write("<style type=\"text/css\">\r\n");
      out.write("<!--\r\n");
      out.write(".IMG{\r\n");
      out.write("\tvertical-align : middle;\r\n");
      out.write("}\r\n");
      out.write("-->\r\n");
      out.write("</style>\r\n");

int ViewPageNumber=5;

Map PageInfo = (Map)request.getAttribute("PageInfo");
	int Page = 0;
	int PageSize = 0;
	int TotalPage = 0;
	try{
	Page = Integer.valueOf((String)PageInfo.get("Page"));
	PageSize = Integer.valueOf((String)PageInfo.get("PageSize"));
	TotalPage = Integer.valueOf((String)PageInfo.get("TotalPage"));
} catch(Exception e){

}
		

		int StartPage=((Page-1)/ViewPageNumber)*ViewPageNumber+1;
		int EndPage=StartPage+ViewPageNumber-1;
		if (EndPage>TotalPage){EndPage=TotalPage;}

		if (StartPage>ViewPageNumber)
		{
			int Pre=StartPage-ViewPageNumber;
			out.print("<a href='javascript:SetPage("+Pre+")'><<</a>&nbsp;");
		}
		for (int IA=StartPage;IA<EndPage+1;IA++)
		{
			if (IA==Page)
			{out.print("<font color='#FF0000'>"+IA+"</font>&nbsp;");}
			else
			{out.print("<a href='javascript:SetPage("+IA+")'>"+IA+"</a>&nbsp;");}
		}
		if (EndPage<TotalPage)
		{
			int Next=EndPage+1;
			out.print("<a href=\"javascript:SetPage("+Next+")\">>></a>&nbsp;");
		}

      out.write("\r\n");
      out.write("第 <strong>");
      out.print(Page);
      out.write("</strong> 頁\r\n");
      out.write("/\r\n");
      out.write("總共 <strong>");
      out.print(TotalPage);
      out.write("</strong> 頁\r\n");
      out.write("跳至&nbsp;<input name=\"Page\" id=\"Page\" type=\"text\" size=\"3\" onchange=\"CheckPage()\" maxlength=\"5\">&nbsp;頁\r\n");
      out.write("&nbsp;&nbsp;<input id=\"gogo\" type=\"image\" src=\"images/go.gif\" name=\"gogo\" name=\"Submit\" title=\"送出\" class=\"IMG\"/>\r\n");
      out.write("\r\n");
      out.write("<script language=\"javascript\">\r\n");
      out.write("function SetPage(page)\r\n");
      out.write("{\r\n");
      out.write("\tdocument.getElementById('Page').value=page;\r\n");
      out.write("\tdocument.getElementById('gogo').click();\r\n");
      out.write("}\r\n");
      out.write("function CheckPage()\r\n");
      out.write("{\r\n");
      out.write("\tif (document.getElementById('Page').value<1)\r\n");
      out.write("\t{document.getElementById('Page').value=1}\r\n");
      out.write("\telse if (document.getElementById('Page').value>");
      out.print(TotalPage);
      out.write(")\r\n");
      out.write("\t{document.getElementById('Page').value=");
      out.print(TotalPage);
      out.write("}\r\n");
      out.write("}\r\n");
      out.write("</script>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
